home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Turnbull China Bikeride
/
Turnbull China Bikeride - Disc 2.iso
/
STUTTGART
/
NEWSOFT
/
OCTOBER
/
PCLTOOLS
/
ASC2PCL
/
A2P.man
next >
Wrap
Text File
|
1997-10-12
|
11KB
|
284 lines
ASC2PCL
=======
A tool to convert ASCII text to PCL (HP Laserjet) or ASCII (i.e. just use
the search-and-replace engine).
You can print the text in various (user-definable) formats, for instance
2 up landscape. You may use any of the printer-resident fonts and use
ASC2PCL's powerful search-and-replace engine, enabling you for instance
to print C code context-sensitive (similar to Zap's coloured C mode).
USAGE:
------
asc2pcl [switches] <infile> [<outfile>]
If no <outfile> is given output is directed to the file "printout".
SWITCHES:
---------
-c x specify characters per line (more precisely: characters with
magnification 1.0) (default: 80)
-d x print every x-th page, default 1 (i.e. every page). The count
is always relative to the first page printed.
-e x encoding number (default 2 - Latin 1)
-f x x = first page
-h x x = file with search/replace patterns (see below)
-i x x = file with font definitions (see below)
-l x x = last page
-m x x = file with format definitions
-n print line numbers (will effectively shrink line width (by 10 chars))
-o0,-o1,-o2 Mode: 0 (PCL, default), 1(ASCII), 2(TEST)
-p x x = number of format to use for this print job (default is 1,
i.e. 2 columns, landscape with the default formats).
-r x x = resolution in dpi
-s x x = promilles of font height to use for linefeeds
(default 1500, i.e. linefeed = 3/2 font height)
-t x x = width of tab columns in characters. I.e. with the
default value of 8 a tab command will move the "cursor"
to the next character position that's a multiple of 8.
-v x verbose mode; x = bitfield. Meaning of bits 0,1,2:
0: Show fonts, 1: Show Formats, 2: Show encodings
-w switch wordwrap mode on (default off). If off lines
are broken as soon as the line width exceeds the maximum
(see -c). Otherwise it's broken at the last space,
comma and a range of similar characters that preceded this
place.
-z x bitfield for specials; meaning of bits 0,1:
0: automatic linefeed off. By default each line of the
input file becomes a line in the output file. If this
bit is set you have to explicitly specify linefeed
characters (see search-and-replace patterns).
1: font styles and weights are taken from the last valid
mode even if they're zero (default: take only if non-zero).
(see search-and-replace patterns).
EXAMPLE:
========
asc2pcl -w -h rep_C -f 2 -l 5 c.foo xyz
Print the file c.foo in wordwrap mode (-w) using search-and-replace patterns from
the file rep_C, print pages 2 to 5 only and print into file <xyz>.
FONTS
-----
Fonts are referenced by their number (internal ASC2PCL numbers, the numbers of the
default fonts are 0,...,7; for an overview see the file Fonts_LJ5). You can have up
to 64 fonts defined (numbers 0,...,63).
Font numbers 64,...,127 have special meaning. They refer to fonts 0,...,63 (i.e.
just subtract 64) but the fonts are forced to be monospaced (which of course only
makes a difference with proportionally spaced fonts). So for instance font number
68 means font number 4, but force monospacing.
Using it on proportionally spaced fonts might be useful sometimes but let me warn
you that it can look rather weird...
A font number of -1 means no (new) font.
SCALING FACTORS
---------------
Scaling factors are relative to the default font size (width of current rectangle
divided by the number of characters per line) in promilles (i.e. 1000 -> 1.0). The
names I use have the meaning:
scale determines how large a font the printer should use. Proportional-spaced fonts
usually should be scaled to 1.5 the size a monospaced font would have.
scalex
scaley determine what size per character ASC2PCL should assume (this is completely
independent of scale). This determines how many characters will fit on a
line and how many lines on a page.
SEARCH AND REPLACE PATTERNS FILE
--------------------------------
The general format is explained in the file rep_C, which does context-sensitive
C/C++ printing. So here's just additional info:
First up you can specify up to 255 modes. These each have their own fonts
defined (or -1 for none) and scaling factors in promilles relative to the font size
actually used. "scale" is the amount to magnify the font by (relevant for the printer
only), "scalex", "scaley" are the relative sizes ASC2PCL should assume (i.e. if you
gave a scalex factor of 500 (=0.5) you'd get twice as many characters on a line). By
default mode 1 is on. Modes are internally numbered from 1 in the order they were
defined in the file.
The font to actually use is determined by scanning through the active modes. The
last one that has a valid font defined wins. The same applies for style and weight
(see also the -z switch). You may have to take this into account if you allow
more than one active mode at any time; the higher the mode's number the higher
its priority.
Each search and replace pattern must have a mode exception list. This is a list
of modes which automatically invalidate the search. If the first character in the
mode exception list is a '!' the mode exception list becomes a mode required list
(i.e. don't except for modes ...).
You may use any printable character but '\' (backlash). That one's used as an
escape character for commands and has to be quoted if you wish to use it (i.e.
if you want to search for "\" you have to write "\\").
Each search is limited to ONE LINE OF THE INPUT FILE! You can't scan over multiple
lines.
Each line starts with 0 and ends with 0. So if you want to search for "foo" at the
beginning of a line you use \&00foo, if you look for this at the end of lines you
use foo\&00. DON'T INSERT A \&00 VIA THE REPLACE STRING (you'll notice that in rep_C
I have a seperate search string for a function at the beginning of a line; that's
to avoid the \&00 being inserted in the replace string along with the other prefixes.).
Each search string must start with a fixed character (otherwise searching with
many patterns would take forever). To avoid having to write lots of basically
identical search strings you may give a list of prefixes (i.e. the first characters)
which can be referenced as '\0' in the search and the replace string. E.g. a prefix
list of {a,b,C-F} and a search string of \0foo will create search patterns for
afoo, bfoo, Cfoo, Dfoo, Efoo and Ffoo.
For identical prefix characters the search patterns that were defined earlier in the
file will be tried first. The main aspect where this is important is in the case of
mode exceptions where you search for the same string but replace it with different
strings depending on the current mode setup. You might for instance want to use
replace pattern 1 if modes A,B,C are off, else pattern 2 if modes B,C are off else
pattern 3 if mode C is off. For this define pattern 1 first, then 2 then 3.
Unless you intend to run the program in -z 2 mode you should never specify linefeed
characters (\&0a) in your replace string. Don't ever specify \&00. In -z 2 mode
text from the input file is read until the line is full or a linefeed was inserted
via a replace string; so this mode is useful if you wish to completely reformat
your input text (for instance printing stuff written at 40 chars per line at 80
chars per line) whereas otherwise each line of the input file becomes a line in
the output file (good for source code printing).
Any characters in the range of 0-31 which aren't part of a found sequence will
be eliminated. So if you e.g. want to retain tabs (\&09) you must replace them with
themselves.
The offset number tells ASC2PCL by how much it should increase the current position
in the line after it has found this pattern. The best way to explain this is an
example (from rep_C):
When searching for functions I look for the characters ' ', '(', and so on, followed
by at least one of the characters a-zA-Z0-9_, any number of spaces/tabs and an
opening bracket. Now this opening bracket could be the prefix for a following
function; so after I found a function I have to go back 1 position in the line
(increase by -1) so I can see if that bracket is starting another function. Note that
in this case you mustn't include the function's opening bracket in the replace string
since otherwise it would appear twice.
Search string:
--------------
Commands:
* any character; e.g. abc*def would match anything that starts with abc and
ends with def.
\&xx character with hex-code xx, e.g. \&2a for '*'.
\* arbitrary repetition of preceding structure/character. E.g. d\* means
any number of d's.
\+ Case sensitive mode on (default off)
\- Case sensitive mode off
\[ Opening bracket for range. If the first character is a '!' this means
any but the specified characters, otherwise only the specified characters.
You may use '-' to specify a continuous range; if you wish to allow the
character '-' you have to use \&2d. Examples: \[a-z.,\] (the letters a
through z, '.' and ','), \[!0-9\] (everything but the numbers 0 through 9).
The contents of a range bracket are always case sensitive!
\] closing bracket for range.
\| OR command, e.g. xxx\|yyy. You should only use this in a \(...\) environment.
\( opening bracket for subexpression. E.g. \(xxx\|yyy\) (xxx OR yyy),
\(xyz\)\* (any repetition of xyz). The contents of the bracket shouldn't end
in a '*' or a "\*" (will be ignored).
\) closing bracket for subexpression.
\{ start of argument for future reference (see \1,...,\9 in Exception / Replace
String). This must never occurr within another \{...\} or \(...\).
\} end of argument.
\n end of line (gets translated to 0)
\0 one of the prefixes given in the prefix list (see above).
Exception string:
-----------------
This is a string of the format \#abc\#def... where '#' is any number from 1 through 9,
giving the number of the argument and the following string up to the next '\' (or end
of the string) is the string this argument must not be. For instance basically C's
"if (...", "while (..." and so on look exactly like functions to the program but I
don't wanna print them as such. Therefore the exception list.
Replace string:
---------------
Commands:
\1,...,\9 insert argument \1,...,\9
\&xx see Search String
\m{mode} increase count of <mode>. Up to 127 is possible (I really hope no one
will need more than this...) A mode is active if it has a count of
at least 1. By default mode 1 is on (1).
\M{mode} decrease count of <mode>
FONT DEFINITION FILE
--------------------
To define the printer resident fonts. Just check out the file "Fonts_LJ5".
FORMAT DEFINITIONS FILE
-----------------------
To define page formats. Check out the file "Formats" for more info.
Commands in the headline/footline:
\c Center printing; may look funny if you're not using a monospaced font at
magnification 1.0
\r Print right-aligned. May look funny...
\# Page number
\f Input file
THIS PROGRAM IS FREEWARE. YOU MAY COPY IT FREELY AS LONG AS NO PART OF IT
IS CHANGED AND IT'S NOT SOLD FOR PROFIT. I RETAIN THE COPYRIGHT.
I WILL NOT ACCEPT ANY RESPONSIBLITY FOR ANY DAMAGES CAUSED BY THE USE OF
THIS PROGRAM, IMPLICITLY OR EXPLICITLY. USE IT ENTIRELY AT YOUR OWN RISK.
Have fun,
Andreas Dehmel
Am Schorn 18
82327 Tutzing
Germany
dehmel@forwiss.tu-muenchen.de